import os

SCRIPT_PATH = os.path.expanduser(os.path.dirname(__file__))
WINDOW_URI = os.getenv('NAUTILUS_SCRIPT_CURRENT_URI')
ABS_PATHS = os.getenv('NAUTILUS_SCRIPT_SELECTED_FILE_PATHS').split()
ABS_URIS = os.getenv('NAUTILUS_SCRIPT_SELECTED_URIS').split()
if len(ABS_PATHS) == 0:
  # use the window URI
  CVS_PATH = WINDOW_URI[WINDOW_URI.find('//')+2:]
if len(ABS_PATHS) == 1 and os.path.isdir(ABS_PATHS[0]):
  # use the full name
  CVS_PATH = ABS_PATHS[0]
else:
  # use the common prefix dirname
  CVS_PATH = os.path.dirname(os.path.commonprefix(ABS_PATHS))
# find the root most CVS path
while 1:
  up = os.path.dirname(CVS_PATH)
  if not os.path.isdir(os.path.join(up, 'CVS')):
    break
  CVS_PATH = up
REL_PATHS = [name[len(CVS_PATH)+1:] for name in ABS_PATHS]
if len(REL_PATHS) == 1 and not REL_PATHS[0]:
  REL_PATHS = ['.']
GLADE_FILE = os.path.join(SCRIPT_PATH, 'ncvs.glade')
#WINDOW_GEOMETRY = os.getenv('NAUTILUS_SCRIPT_WINDOW_GEOMETRY').split()
